package com.utils;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpReq {
    HttpURLConnection con = null;
    StringBuilder str = new StringBuilder();
    BufferedReader br = null;
    URL address = null;
    String line = null;

    HttpReq () {
      try {
        address = new URL("http://www.jxfgt.net/");
        address = new URL("http://www.4399.com/");
        con = (HttpURLConnection)address.openConnection();
        con.setRequestMethod("GET");
        con.setReadTimeout(60000);
        con.setConnectTimeout(60000);
        con.setDoOutput(true);
        con.setInstanceFollowRedirects(true);

        con.connect();

        InputStreamReader is  = new InputStreamReader(con.getInputStream());
        br = new BufferedReader(is);
        while((line = br.readLine()) != null)
        {
            str.append(line + '\n');
        }
        //System.out.println(str);
        System.out.println(con.getResponseCode());
        System.out.println(con.getResponseMessage());
      }
      catch (Exception m)
      {
        m.printStackTrace();
      }
      finally
      {
        br = null;
        str = null;
        con = null;
      }
  }

  public static void main(String[] args) {
    HttpReq http = new HttpReq();
      }

}